<?php echo $this->render('link/header.phtml') ?>
//常用变量初始化
var menuCheckUrl=baseUrl+"/link/serverclient/type/check";
var menuEditUrl=baseUrl+"/link/serverclient/type/edit";
var module="client";
var gridTitle="客户信息审核";
var dataId="client_id";
var Client = Ext.data.Record.create([
           {name: 'client_id', type: 'int'},
           {name: 'client_company', type: 'string'},
		   {name: 'client_industry', type: 'string'},
           {name: 'client_host', type: 'string'},
           {name: 'client_keyword', type: 'string'},
           {name: 'client_keyword_link', type: 'string'},
           {name: 'client_keyword_count', type: 'string'},
           {name: 'client_ischeck', type: 'string'},
      ]);

industry_combo_store.load();      
var industry_combo=new Ext.form.ComboBox({
										 fieldLabel:'role',
										 store:industry_combo_store,										
        								displayField:'industry_name',
        								valueField :'industry_id',
										hiddenName:"industry_id",
        								typeAhead:true,
        								mode:'local',
        								triggerAction:'all',
                                        editable:false,  
        								emptyText:'请选择...',
        								selectOnFocus:true
										 });    
var ds=new Ext.data.Store({
							  proxy:new Ext.data.HttpProxy({
									url:baseUrl+'/link/serverclient/type/getAll'
									}),
							  reader:new Ext.data.JsonReader({
									root:'results',
									totalProperty:'total',
									id:'u_id'
									},Client)
	});		 
//定义列模型
var cm=new Ext.grid.ColumnModel([	
							new Ext.grid.CheckboxSelectionModel(),
                            {header:'客户ID',dataIndex:'client_id',width:30,hidden:true},														
							{header:'公司名称',dataIndex:'client_company',width:150},
							{header:'所属行业',dataIndex:'client_industry',width:150,editor:industry_combo,renderer:function(value,cell,record){                           
                            var index=industry_combo.getStore().find(industry_combo.valueField,value);
                            var record=industry_combo.getStore().getAt(index);                         
                           	if(record){
                            return record.data.industry_name;
                            }
                            else{
                            return value;
                            }
                            }},
							{header:'域名',dataIndex:'client_host',width:100},
                            {header:'关键词',dataIndex:'client_keyword',width:200,hidden:true},						
                            {header:'关键词链接',dataIndex:'client_keyword_link',width:200,hidden:true},						
                            {header:'关键词次数',dataIndex:'client_keyword_count',width:100,hidden:true},
                            {header:'审核状态',dataIndex:'client_ischeck',width:50,renderer:show_check_status}						
	]);
cm.defaultSortable = true; 



//定义工具栏								 
var tb=new Ext.Toolbar({
							items:[

                                         {
                                            id:'menuCheck'+ExtId,
											text:'审核通过',
											iconCls:'icn-ok',
											handler:menuCheckOk
											},
                                              {
                                            id:'menuCheck'+ExtId,
											text:'审核失败',
											iconCls:'icn-cross',
											handler:menuCheckError
											}										 
								 ]
	});			
   
function menuCheckOk(){
menuCheck(true);
}
function menuCheckError(){
menuCheck(false);
}

function menuCheck(flag){
	var selectRows=grid.getSelectionModel().getSelections();												
												if(selectRows.length==0){
													Ext.MessageBox.alert('提示','请选择一条数据');
													}
												else{		
													var message="";
													for(var i=0;i<selectRows.length;i++){
														if(i!=0){
															message+=",";
															}
														message+=selectRows[i].get(dataId);
														}
													Ext.Ajax.request({
																	 url:menuCheckUrl,
																	 params:{id:message,flag:flag},																																		 																	success:function(response,option){
																var temp=Ext.util.JSON.decode(response.responseText);																
																ds.load({params:{start:0,limit:30}});
																grid.render();
																		 },
																	failure:function(response,option){
																		var temp=Ext.util.JSON.decode(response.responseText);
																		Ext.MessageBox.alert('waring',temp.msg);
																		}
																	 });
													}
}

<?php echo $this->render('link/foot.phtml') ?>
